//
//  CollectionChooseViewCell.m
//  Select
//
//  Created by dihuijun on 17/3/20.
//  Copyright © 2017年 Cycle. All rights reserved.
//

#import "CollectionChooseViewCell.h"

#define SelectNum_ItemHeight 51
#define SelectNum_ItemWidth 77
#define ItemFont1 17
#define ItemFont2 16

@implementation CollectionChooseViewCell

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.frame = frame;
        ///创建子控件
        [self setupChildren];
        
    }
    return self;
}
#pragma mark --- 创建子控件
- (void)setupChildren
{
    //1.创建按钮
    self.selectedButton = [UIButton buttonWithType:UIButtonTypeCustom];
    //不可以触摸
    self.selectedButton.userInteractionEnabled = NO;
    //颜色
    [self.selectedButton setTitleColor:[UIColor lightGrayColor] forState:UIControlStateNormal];
    //普通状态下图片
    [self.selectedButton setImage:[UIImage imageNamed:@"collectview_Unselect"] forState:UIControlStateNormal];
    //选中状态下图片
    [self.selectedButton setImage:[UIImage imageNamed:@"collectview_Selected"] forState:UIControlStateSelected];
    [self.contentView addSubview:self.selectedButton];
    //布局
    [self.selectedButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.contentView.mas_left).offset(0);
        make.top.mas_equalTo(self.contentView.mas_top).offset(0);
        make.right.mas_equalTo(self.contentView.mas_right).offset(0);
        make.bottom.mas_equalTo(self.contentView.mas_bottom).offset(0);
    }];
    
    
    
    ////2.titleLabel
    self.titleLabel = [UILabel new];
    self.titleLabel.textColor = [UIColor darkTextColor];
    self.titleLabel.font      = [UIFont systemFontOfSize:16.0];
    self.titleLabel.textAlignment = NSTextAlignmentCenter;
    [self.contentView addSubview:self.titleLabel];
    //布局
    [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.mas_left);
        make.right.mas_equalTo(self.mas_right);
        make.top.mas_equalTo(self.mas_top);
        make.bottom.mas_equalTo(self.mas_bottom);
    }];
    
    
    
    
    
    
    
    
    
    
    
}

/**
 *  更新选中状态
 */
- (void)updateCellSelectedState:(BOOL)select{
    self.selectedButton.selected = select;
    self.isSelected = select;
}
@end
